﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Admin.Master" Inherits="System.Web.Mvc.ViewPage<IList<DocumentInfo>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    API Document - Open API Control Panel
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <fieldset>
        <legend>Document Manage &gt; List</legend>
        <table border="0" cellpadding="0" cellspacing="0" width="100%">
            <tr>
                <td width="70" align="center">
                    <strong>Doc Code</strong>
                </td>
                <td>
                    <strong>Doc Subject</strong>
                </td>
                <td width="140" align="center">
                    <strong>Doc Datetime</strong>
                </td>
                <td width="120" align="center">
                    <strong>Manage</strong>
                </td>
            </tr>
            <%
                foreach (DocumentInfo doc in Model)
                {
            %>
            <tr>
                <td width="70" align="center">
                    <%= doc.DOC_CD%>
                </td>
                <td>
                    <%= Html.ActionLink(doc.DOC_SUBJECT, "Pop_DocView", "Document", new { id = doc.DOC_CD }, new { @class = "nyroModal", @target = "_blank" })%>
                </td>
                <td align="center">
                    <%= doc.DOC_DATETIME%>
                </td>
                <td width="120" align="center">
                    [<%= Html.ActionLink("Modify", "Modify", "Document", new { id = doc.DOC_CD }, null)%>]
                    [<%
                         Response.Write("<a href=\"javascript:void(0);\" onclick=\"javascript:AjaxDeleteDoc('" + doc.DOC_CD + "');\">Delete</a>");
                    %>]
                </td>
            </tr>
            <%
                }
            %>
        </table>
        <input type="button" id="btnAddDocument" name="btnAddDocument" value="Add Document" />
    </fieldset>

    <script type="text/javascript" language="javascript">

        //json: Submit
        function AjaxDeleteDoc(doc_cd) {

            if (confirm('Are you sure Delete？')) {
                $.post("/Document/Delete?" + new Date(), {
                    Action: "post",
                    doc_cd: doc_cd
                }, function(result) {
                    if (result.FLAG) {
                        alert("Sucess");
                        location.href = '/Document/List';
                    }
                    else {
                        alert(result.DESC);
                    }
                })
            }
        }

        $().ready(function() {
            $("#btnAddDocument").click(function() {
                location.href = "/Document/Add";
            })
        })
    </script>

    <script type="text/javascript">
        $(function() {
            $.nyroModalSettings({ width: 650 });
        });
    </script>

</asp:Content>
